asm
  ld sp,$33FF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $3010
dim seed as uinteger at $3012
dim ee0 as uinteger at $3014
dim ee1 as uinteger at $3016
dim ee2 as uinteger at $3018
dim ee3 as uinteger at $301A
dim ex0 as uinteger at $301C
dim ey0 as uinteger at $301E

sub cheekymouseputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte)
  poke $3800+txp1*32+typ1 bxor 31,tch1
  end sub

seed=0

for ee1=0 to 31
  for ee0=0 to 31
    seed=smsrnd(seed)
    cheekymouseputchar(ee0,ee1,96+(seed mod 54))
    next:next

for ee1=0 to 15
  for ee0=0 to 15
    cheekymouseputchar(ee0+11,ee1+15,ee1*16+ee0)
    next:next

eee=0:ex0=8:ey0=8
do

cheekymouseputchar(5,1,48+int(eee/10000) mod 10)
cheekymouseputchar(6,1,48+int(eee/1000) mod 10)
cheekymouseputchar(7,1,48+int(eee/100) mod 10)
cheekymouseputchar(8,1,48+int(eee/10) mod 10)
cheekymouseputchar(9,1,48+eee mod 10)

ee0=in($00) bxor $FF
cheekymouseputchar(7,3,48+int(ee0/100) mod 10)
cheekymouseputchar(8,3,48+int(ee0/10) mod 10)
cheekymouseputchar(9,3,48+ee0 mod 10)

ee0=in($01) bxor $FF
cheekymouseputchar(7,4,48+int(ee0/100) mod 10)
cheekymouseputchar(8,4,48+int(ee0/10) mod 10)
cheekymouseputchar(9,4,48+ee0 mod 10)

ey0=ey0+((ee0 band 4)/4)-((ee0 band 8)/8)
ex0=ex0+((ee0 band 32)/32)-((ee0 band 64)/64)

cheekymouseputchar(ex0,ey0,eee band 127)

smsdelay(1000)
eee=eee+1
loop



do:loop

'for eee=$3800 to $3BFF
'  seed=smsrnd(seed)
'  'poke eee,seed
'  poke eee,96+(seed mod 54)
'  smsdelay(1000)
'  next






do
for eee=$3800 to $3BFF
  seed=smsrnd(seed)
  'poke eee,seed
  poke eee,96+(seed mod 54)
  smsdelay(1000)
  next
loop

do:loop


'static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, cheekyms_state )
'AM_RANGE(0x0000, 0x1fff) AM_ROM
'AM_RANGE(0x3000, 0x33ff) AM_RAM
'AM_RANGE(0x3800, 0x3bff) AM_RAM AM_SHARE("videoram")
'ADDRESS_MAP_END

'static ADDRESS_MAP_START( io_map, AS_IO, 8, cheekyms_state )
'ADDRESS_MAP_GLOBAL_MASK(0xff)
'AM_RANGE(0x00, 0x00) AM_READ_PORT("DSW")
'AM_RANGE(0x01, 0x01) AM_READ_PORT("INPUTS")
'AM_RANGE(0x20, 0x3f) AM_WRITEONLY AM_SHARE("spriteram")
'AM_RANGE(0x40, 0x40) AM_WRITE(port_40_w)
'AM_RANGE(0x80, 0x80) AM_WRITE(port_80_w) AM_SHARE("port_80")
'ADDRESS_MAP_END
